<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>国家智造设计服务云平台</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<!--<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8" />-->
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" type="text/css" href="css/font.css">
		<link rel="stylesheet" type="text/css" href="css/common.css">
		<link rel="stylesheet" type="text/css" href="css/theme10.min.css">
		<link rel="stylesheet" type="text/css" href="css/index.css"/>

		<style>
			.changePwdDiv{
				background-color: #fff;
				box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);
				padding: 20px;
				/*max-width: 1360px;*/
				margin-left: 10px;
				margin-right: 10px;
				margin-top: 10px;
				box-sizing: border-box;
			}
			.changePwdForgetFormForget{
				display: none;
			}

			#nav div.sml_title_top {
				padding-top: 18px;
			}
			.userInfoDiv {
				background-color: #fff;
				box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .2);
				padding: 20px;
				/*max-width: 1360px;*/
				margin-left: 10px;
				margin-right: 10px;
				margin-top: 10px;
				box-sizing: border-box;
			}
		</style>
	</head>

	<body class="index">
		<!-- 顶部开始 -->
		<div class="container">
			<div class="logo">
				<a href="./index.html">智造·创新设计云平台</a>
			</div>

			<div class="left_open">
				<a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
			</div>

			<ul class="layui-nav right" lay-filter="">
				<li class="layui-nav-item"><a href="http://www.inno-design.org.cn">首页</a></li>
				<li class="layui-nav-item">
					<a href="javascript:;"><span id="userAccount"></span></a>
					<dl class="layui-nav-child">
						<dd>
							<a href="#" id="userInfo">账号信息</a>
						</dd>
						<dd>
							<a href="#" id="changePwd">修改密码</a>
						</dd>
						<dd>
							<a href="#" id="logout">退出</a>
						</dd>
					</dl>
				</li>
			</ul>
		</div>
		<!-- 顶部结束 -->

		<!-- 左侧菜单开始 -->
		<div class="left-nav noScrollBar">
			<div id="side-nav">
				<ul id="nav"></ul>
			</div>
		</div>
		<!-- 左侧菜单结束 -->

		<!-- 右侧主体开始 -->
		<div class="page-content">
			<div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show">
						<iframe src='' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
					</div>
				</div>
			</div>
		</div>


		<div class="changePwdDiv">
			<div class="changePwdForm">
				<form class="layui-form " action="" id="changePwdForm">
					<input type="hidden" class="save_val" name="id" value="" />
					<div class="layui-form-item">
						<!--<label class="layui-form-label">输入原密码：</label>-->
						<input type="password" class="layui-input chgOldPassword save_val" name="chgOldPassword" required lay-verify="required"
							   placeholder="输入原密码" autocomplete="off">
					</div>

					<div class="layui-form-item">
						<!--<label class="layui-form-label">输入新密码：</label>-->
						<input type="password" class="layui-input chgNewPassword save_val" name="chgNewPassword" required lay-verify="required"
							   placeholder="输入新密码" autocomplete="off">
					</div>

					<div class="layui-form-item">
						<!--<label class="layui-form-label">再次输入新密码：</label>-->
						<input type="password" class="layui-input chgReNewPassword save_val" name="chgReNewPassword" required lay-verify="required"
							   placeholder="再次输入新密码" autocomplete="off">
					</div>
					<div class="layui-form-item" style="text-align: right;">
						<a href="#" style="text-decoration: underline;" class="iForgetPwd">忘记密码</a>
					</div>
					<div class="layui-form-item">
						<button type="button" class="layui-btn  layui-btn-normal changePwdSubmitWithPwd" style="width: 100%;">保存</button>
					</div>

				</form>
			</div>
			<div class="changePwdForgetFormForget">
				<form class="layui-form " action="" id="changePwdForgetFormForget">
					<div class="layui-form-item">
						<!--<label class="layui-form-label">输入原密码：</label>-->
						<input type="text" class="layui-input chgPhoneNum save_val" name="phone" required lay-verify="required"
							   placeholder="手机号" autocomplete="off">
					</div>

					<div class="layui-form-item" style="display: flex;flex-direction: row;flex-wrap: nowrap;">
						<!--<label class="layui-form-label">输入新密码：</label>-->
						<input type="text" class="layui-input chgAuthCode save_val" name="chgAuthCode" required lay-verify="required"
							   placeholder="输入验证码" autocomplete="off"><button type="button" class="layui-btn  layui-btn-normal getAudoCode">获取验证码</button>
					</div>

					<div class="layui-form-item">
						<!--<label class="layui-form-label">再次输入新密码：</label>-->
						<input type="password" class="layui-input chgPasswordWithAuto save_val" name="chgPasswordWithAuto" required lay-verify="required"
							   placeholder="输入密码" autocomplete="off">
					</div>
					<!--<div class="layui-form-item" style="text-align: right;">-->
					<!--<a href="#" style="text-decoration: underline;" class="iForgetPwd">忘记密码</a>-->
					<!--</div>-->
					<div class="layui-form-item">
						<button type="button" class="layui-btn  layui-btn-normal changePwdSubmitWithAuthCode" style="width: 100%;">保存</button>
					</div>

				</form>
			</div>
		</div>
		<div class="userInfoDiv">
			<div class="userInfoForm">
				<form class="layui-form " action="" id="userInfoForm">
					<input type="hidden" class="save_val" name="id" value=""/>
					<div class="layui-form-item">
						账号：
						<input type="text" class="layui-input registerAccount save_val" name="registerAccount"
							   required lay-verify="required"
							   placeholder="账号" autocomplete="off" disabled>
					</div>

					<div class="layui-form-item">
						邮箱：
						<input type="text" class="layui-input registerEmail save_val" name="registerEmail" required
							   lay-verify="required"
							   placeholder="邮箱地址" autocomplete="off">
					</div>


					<div class="layui-form-item">
						<button type="button" class="layui-btn  layui-btn-normal changeAccount" style="width: 100%;">保存</button>
					</div>

				</form>
			</div>
		</div>
		<!-- 右侧主体结束 -->

		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/config.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/menu.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function() {
				layui.use('form', function() {
					var form = layui.form;

					// 获取用户account
					setTimeout(function () {

						getUserInfo();
						checkInfoComplete();

					},1000);
					setInterval(function () {
						checkInfoComplete();
					}, 5000);

					$("#logout").on('click',function () {
						var params = {};

						$.ajax({
							url: cgiMain.applicantLogout,
							dataType: 'json',
							data: params,
							xhrFields: {
								withCredentials: true
							},
							contentType: false,
							type: 'GET',
							cache: false,
							timeout: CFG.TIMEOUT,
							async:false,
							success: function(res) {
								if (res.code== '0000') {
									clearCookie();
									location.href = 'http://www.inno-design.org.cn';
								}

							},
							error: function() {}});
						return false;
					});


				});

				$(".changePwdSubmitWithAuthCode").on('click',function () {
					var params = {};
					params.authCode = $(".chgAuthCode").val();
					params.phoneNum = $(".chgPhoneNum").val();
					params.password = $(".chgPasswordWithAuto").val();
					params.type=2;
					params.roleId=1;
					changePwd(params);
					return false;

				});

				function changePwd(params){
					$.ajax({
						url: cgiMain.userChangePwd,
						dataType: 'json',
						data: params,
						xhrFields: {
							withCredentials: true
						},
						contentType: false,
						type: 'GET',
						cache: false,
						timeout: CFG.TIMEOUT,
						async:false,
						success: function(res) {
							if(res.result){
								alert(res.result);
							}else{
								alert(res.msg);
							}

							if (res.code== '0000') {
								layer.close(chgPwdIndex);
							}

						},
						error: function() {}});
				}

				$(".changePwdSubmitWithPwd").on('click',function () {
					var params = {};

					params.oldPassword = $(".chgOldPassword").val();
					params.password = $(".chgNewPassword").val();
					params.rePassword = $(".chgReNewPassword").val();
					params.type=1;
					params.roleId=1;
					if(params.password !== params.rePassword){
						layer.msg("新密码两次输入不一致，请重试");
						return false;
					}
					changePwd(params);
					return false;
				});

				$(".getAudoCode").on('click',function () {
					var params={};
					params.type=2;
					params.roleId=1;
					params.phoneNum = $(".chgPhoneNum").val();
					getAuthCode(params);
					return false;
				});

				function getAuthCode(params) {
					$.ajax({
						url: cgiMain.applicantAuthCode,
						dataType: 'json',
						data: params,
						xhrFields: {
							withCredentials: true
						},
						contentType: false,
						type: 'GET',
						cache: false,
						timeout: CFG.TIMEOUT,
						async:false,
						success: function(res) {
							if(res.result){
								alert(res.result);
							}else{
								alert(res.msg);
							}
							if (res.code== '0000') {

							}

						},
						error: function() {}});
				}

				$(".changeAccount").on('click', function () {
					var params = {};
					params.account = $(".registerAccount").val();
					params.email = $(".registerEmail").val();
					params.phoneNum = $(".chgPhoneNum").val();
					params.roleId = 1;
					changeAccount(params);
					getUserInfo();
					return false;

				});

				function changeAccount(params) {
					$.ajax({
						url: cgiMain.applicantUpdateUser,
						dataType: 'json',
						data: params,
						xhrFields: {
							withCredentials: true
						},
						contentType: false,
						type: 'GET',
						cache: false,
						timeout: CFG.TIMEOUT,
						async: false,
						success: function (res) {
							if (res.result) {
								alert(res.result);
							} else {
								alert(res.msg);
							}

							if (res.code == '0000') {
								layer.close(chgUserIndex);
							}

						},
						error: function () {
						}
					});
				}
				var chgUserIndex;

				$("#userInfo").on("click", function () {
					// $("#myModal").show();
					chgUserIndex = layer.open({
						type: 1,
						title: '账号信息',
						area: ['500px', '350px'],
						content: $(".userInfoDiv") //这里content是一个普通的String
					});
					$(".userInfoForm").show();
					return false;
				});

				function getUserInfo(){
					AJAX.query(cgiMain.getUserInfo,
							{},
							function (res) {
								if (res.code == "0000") {
									$("#userAccount").html(res.result.account);
									$(".registerAccount").val(res.result.account);
									$(".registerEmail").val(res.result.email);
									$(".chgPhoneNum").val(res.result.phone);
								}
							});
				}

				$("#changePwd").on("click",function () {
					// $("#myModal").show();
					var phoneNum =$(".chgPhoneNum").val();
					$(".changePwdDiv input, .changePwdDiv textarea").val("");
					$(".chgPhoneNum").val(phoneNum);
					chgPwdIndex = layer.open({
						type: 1,
						title:'修改密码',
						area: ['500px', '350px'],
						content: $(".changePwdDiv") //这里content是一个普通的String
					});
					$(".changePwdForgetFormForget").hide();
					$(".changePwdForm").show();
					return false;
				});

				$(".iForgetPwd").on("click",function () {
					$(".changePwdForgetFormForget").show();
					$(".changePwdForm").hide();
					return false;
				});



				function clearCookie() {
					var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
					if (keys) {
						for (var i = keys.length; i--;) {
							document.cookie = keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString();
							document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + new Date(0).toUTCString();
							document.cookie = keys[i] + '=0;path=/;domain=kevis.com;expires=' + new Date(0).toUTCString();
						}
					}
				}
			})
		</script>
	</body>

</html>
